package com.example.spring.aop.tx.anno.service.impl;

import com.example.spring.aop.tx.anno.service.AccountService;
import com.example.spring.aop.tx.anno.dao.AccountDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Service
public class AccountServiceImpl implements AccountService {

    @Resource
    private AccountDao accountDao;

    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
    @Override
    public void transfer(String outer, String inner, int money) {
        accountDao.out(outer, money);
//        int i = 1/0;
        accountDao.in(inner, money);
    }
}
